<script src="../media/system/js/mootools-core.js" type="text/javascript"></script>
<script src="../media/system/js/core.js" type="text/javascript"></script>
<form action="index.php?top=page&option=com_frclub" method="post" name="adminForm" id="adminForm" class="adminform">
<!-- LEFT -->
 <?php echo $this->loadTemplate('search','default') ?>
 <!-- END LEFT -->
 
 <!-- CONTENT -->
 <div id="jm-content">
    <div class="cc title">
        <div class="id"><?php echo $this->info_ocba->OCBA_CODE; ?></div>
        <div class="cc-title">
            <p class="top"><?php echo $this->info_ocba->OCBA_KANA; ?></p>
            <p class="bot"><?php echo $this->info_ocba->OCBA_NAME; ?><span class="float-right">【<?php echo $this->info_ocba->OCBA_SHOR; ?>】</span></p>
        </div>
    </div>
    <div class="clearfix"></div>
    <div class="menu-cc">
        <ul id="nav">
        <?php 
            foreach(bgData::getMenuDetailClub() as $key=>$item){
                $acctive = 'normal';
                if(JRequest::getVar('task') == $key){
                    $acctive = 'current';
                }
         ?>
            <li class="<?php echo $acctive; ?>"><a href="index.php?top=page&option=com_frclub&task=<?php echo $key; ?>&id=<?php echo $this->info_ocba->OCBA_CODE; ?>"><?php echo $item; ?></a></li>
          <?php } ?>
            
        </ul>
    </div>
   <div id="">
   <h3 class="h_title">活動人数
       <!-- <span style="float: right;">更新日:<?php //if($this->row->ACTT_DATE!='0000-00-00 00:00:00') echo HelperBG::F_GetDate_JP($this->row->ACTT_DATE); ?></span>-->
   </h3>
    <div class="info-basic">                                            
        <div>
                    <table style="width: 100%;" border=0>
                        <tr>
                            <td colspan="2">年度： 
                                    <select id="jformcboyear" name="year">
                                    <?php 
                                        $year = JRequest::getVar('year');
                                        echo HelperBG::getYearOption($year);
                                    ?>
                                    
                                    </select>
                                        年度
        
                                </td>
                        </tr>
                        
                   </table>
                   <div class="title_">活動人数集計</div>

                    <table width="100%" cellpadding="0" cellspacing="0" id="tb_count" border=0>
                        <tbody>
                            <tr class="titleth">
                                <td style='visibility:hidden'></td>
                                <td class='left'><b>ジャンル</td>
                                <?php
                                foreach ($this->statistic['head'] as $head){
                                    echo "<td><b>$head</b></td>";
                                }
                                ?>
                                <td><b>合計</b></td>
                            </tr>
                            <?php
                            $sum_color = "background: #4AC0FF;";
                            $cell_width = 88/13 ."%";
                            $rowspan = count($this->pacm);
                            foreach($this->actm as $actm_key => $actm){
                                echo "<tr>";
                                echo "<td rowspan= $rowspan class='titleth' style='width: 4%;'>$actm->ACTM_NAME</td>";
                                foreach($this->pacm as $pacm_key => $pacm){
                                    $color = $pacm->PACM_NUMF == 1 ? "background: #ADE2FF;" : "";
                                    echo "<td style='width: 8%; $color'>$pacm->PACM_NAME</td>";
                                    foreach($this->statistic['uscl_data'][$actm->ACTM_CODE][$pacm->PACM_CODE] as $row){
                                        echo "<td class='center' style='width: $cell_width; $color'>$row</td>";
                                    }
                                    $sum_row = empty($this->statistic['sum_row'][$actm->ACTM_CODE][$pacm->PACM_CODE]) ? '-' : $this->statistic['sum_row'][$actm->ACTM_CODE][$pacm->PACM_CODE];
                                    echo "<td class='center' style='width: $cell_width; $color'>$sum_row</td>";
                                    echo "</tr>";
                                }
                                
                            }
                            echo "<tr>";
                            echo "<td colspan='2' class='titleth' style=''>合計人数</td>";
                            foreach($this->statistic['sum_col'] as $sum){
                                echo "<td class='center' style='width: $cell_width; $sum_color'>$sum</td>";
                            }
                            $total = array_sum($this->statistic['sum_col']) == 0 ? '-' : array_sum($this->statistic['sum_col']);
                            echo "<td class='center' style='width: $cell_width; $sum_color'>$total</td>";
                            echo "</tr>";
                            
                            //
                            echo "<tr>";
                            echo "<td colspan='2' class='titleth'>合計活動日数</td>";
                            foreach($this->statistic['sum_col2'] as $sum){
                                echo "<td class='center' style='width: $cell_width;'>$sum</td>";
                            }
                            $total = array_sum($this->statistic['sum_col2']) == 0 ? '-' : array_sum($this->statistic['sum_col2']);
                            echo "<td class='center' style='width: $cell_width;'>$total</td>";
                            echo "</tr>";
                            ?>
                        </tbody>
                    </table>
                    <input type="hidden" name="task" id="_task" value=""/>
                    <input type="hidden" name="id" value="<?php $id = JRequest::getVar('id'); echo $id?>"/>

                    
        </div>
    </div>
 </div>                                
    
 </div>
 </form>
 <script>
    jq(document).ready(function(){
        jq('#jformcboyear').change(function(){
            jq('#_task').val('count');
            jq('#adminForm').submit();
        });

        format_table('#tb_count');
    });

    function format_table(target){
        jq(target + ' td').each(function(){
            if(!isNaN(parseInt(jq(this).html()))){
                this.style.textAlign = "right";
            }
        });
    }
 </script>
 <!-- END CONTENT -->
                           